package com.tianji.promotion.controller;


import com.tianji.api.dto.promotion.CouponDiscountDTO;
import com.tianji.api.dto.promotion.OrderCourseDTO;
import com.tianji.promotion.service.IDiscountService;
import com.tianji.promotion.service.IUserCouponService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户领取优惠券的记录，是真正使用的优惠券信息 前端控制器
 * </p>
 *
 * @author 优惠卷模块
 * @since 2023-04-22
 */
@RestController
@RequestMapping("/user-coupon")
@RequiredArgsConstructor
public class UserCouponController {


    private final IUserCouponService couponService;

    private final IDiscountService service;

    /**
     * 领取优惠卷
     */
    @ApiOperation("领取优惠卷接口")
    @PostMapping()
    public void receiveCoupon(@PathVariable("couponId") Long couponId){
        couponService.receiveCoupon(couponId);
    }

    /**
     * 兑换码兑换优惠卷
     */
    @ApiOperation("兑换码兑换优惠卷接口")
    @PostMapping("/{code}/exchange")
    public void CodeCoupon(@PathVariable("code")String code){
        couponService.CodeCoupon(code);
    }


    @ApiOperation("查询我的优惠劵测试方案")
    @PostMapping("/available")
    public List<CouponDiscountDTO> findDiscountSolution(List<OrderCourseDTO> orderCours){
        return service.findDiscountSolution(orderCours);
    }

}
